package com.hive.decode;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Abc {
    public static void main(String[] args) throws Exception {

        Connection conn = aa();
        Statement statement = conn.createStatement();

        String sql = "SELECT * FROM test2.data_collection_summary_details_2020 LIMIT 100";
//        String sql = "select * from tools.a limit 1";
//        String sql = "select * from tools.a limit 1";
//        String sql = "select * from tools.a limit 1";

        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()) {
            String a = resultSet.getString(1);
            String b = resultSet.getString(2);
            String c = resultSet.getString(3);
            String d = resultSet.getString(4);
            System.out.println("a = " + a);
            System.out.println("b = " + b);
            System.out.println("c = " + c);
            System.out.println("d = " + d);
        }

        conn.close();

    }

    public static Connection conn=null;

    public static Connection aa()throws Exception{

        if(conn==null){
            Class.forName("org.apache.hive.jdbc.HiveDriver");
//            conn=  DriverManager.getConnection("jdbc:hive2://0.1.1.180:10000/user/hive/warehouse/ods_rmy_data.db/","hive","hive");
            conn=  DriverManager.getConnection("jdbc:hive2://10.1.1.153:10000/old-hive/test2","sanbuuser","huaYrtw9p2hB6kun");
        }
        return conn;
    }
}
